package jiachunlei.chain;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/12/10 23:22
 */
public class ChainClient
{
    private static AbstractLogger getChainOfLoggers()
    {

        AbstractLogger errorLogger = new ErrorLogger(AbstractLogger.ERROR);
        AbstractLogger fileLogger = new FileLogger(AbstractLogger.DEBUG);
        AbstractLogger consoleLogger = new ConsoleLogger(AbstractLogger.INFO);

        errorLogger.setLogger(fileLogger);
        fileLogger.setLogger(consoleLogger);

        return errorLogger;
    }

    public static void main(String[] args)
    {
        AbstractLogger loggers = getChainOfLoggers();
        loggers.logMessage(AbstractLogger.INFO, "This is an information.");
        loggers.logMessage(AbstractLogger.DEBUG, "This is a debug level information.");
        loggers.logMessage(AbstractLogger.ERROR, "This is an error information.");
    }
}
